<!--
* description: 采购销退申请单财务审核
* author: wangjuan
* createdDate:2021-3-1
-->
<template>
  <section class="editpurchaseFinanceAudit">
    <el-dialog
      v-dialogDrag
      :visible.sync="curPopupsVisible"
      :title="textMap[popupsState]"
      :append-to-body="true"
      width="70%"
      :close-on-click-modal="false"
      @close="closeEdit"
    >
      <dialogHeader
        slot="title"
        :title="titleName"
        :style-type="$store.state.app.dialogType"
      />

      <div class="app-container app-container-table">
        <one-table-template
          ref="multipleTable"
          :key="oneTableKey"
          :dynamic-buttons="tableButtons"
          :dynamic-components="tableComponents"
          :dynamic-api-config="apiConfig"
          :dynamic-table-cols="tableCols"
          :dynamic-form-fields="formField"
          :dynamic-is-show-select="false"
          :dynamic-is-init-table="true"
          :dynamic-table-defult-height="300"
        />
      </div>
    </el-dialog>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from '@/components/mixins/oneTableWithViewTemplateMixins'
import { formMixins } from '@/components/mixins/formMixins'
import OneTableTemplate from '@/components/templates/oneTable'
import api from '@/api/pa/procuremenData'

export default {
  components: {
    dialogHeader: () => import('@/components/dialogHeader'),
    OneTableTemplate
  },
  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins, formMixins],

  props: {
    dynamicEditRowData: { type: Object, default: () => { return {} } },
    // 弹出是否显示
    popupsVisible: { type: Boolean, default: false },
    customObj: { type: Object, default: () => { return {} } }
  },

  data() {
    const viewPageCode = 'purchaseFinance-Edit'
    return {
      titleName: '销退申请单明细',
      apiConfig: api.purchasePinBackBusinessQueryDetail,

      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[viewPageCode] &&
          this.$ConfigCache.CacheConfig.cacheData[viewPageCode].formComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[viewPageCode].formComponents
          : [
            {
              compKey: 'compKey1',
              labelName: '销退类型：',
              codeField: 'purReturnTypeName',
              component: () => import('@/components/org/LookupValue'),
              type: 'dropdownList',
              disabled: true,
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey2',
              labelName: '销退单号：',
              codeField: 'purReturnCode',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              disabled: true,
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey5',
              labelName: '网点编码：',
              codeField: 'dlrCode',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              disabled: true,
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey6',
              labelName: '网点名称：',
              codeField: 'dlrShortName',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              disabled: true,
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey3',
              labelName: '销退日期：',
              codeField: 'returnDate',
              component: () => import('@/components/org/commonInput'),
              dateType: 'inputText',
              disabled: true,
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey7',
              labelName: '销退总金额',
              codeField: 'returnAmount',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              disabled: true,
              isMul: false,
              isMust: true
            },
            {
              compKey: 'compKey8',
              labelName: '销退申请原因',
              codeField: 'returnReason',
              component: () => import('@/components/org/commonInput'),
              type: 'inputText',
              disabled: true,
              isMul: false,
              isMust: true
            }
          ],

      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
            {
              prop: 'partId',
              label: '备件ID',
              hidden: true,
              alwaysHidden: true
            },
            {
              prop: 'purReturnDId ',
              label: '子单ID',
              hidden: true,
              alwaysHidden: true
            },
            {
              prop: 'partNo',
              label: '备件编码'
            },
            {
              prop: 'partName',
              label: '备件名称'
            },
            {
              prop: 'inStoreQty',
              label: '入库数量'
            },
            {
              prop: 'optionalPagName',
              label: '入库异常数量',
              hidden: true,
              alwaysHidden: true
            },
            {
              prop: 'carColorName',
              label: '入库异常原因',
              hidden: true,
              alwaysHidden: true
            },
            {
              prop: 'inventoryQuantity',
              label: '库存数量'
            },
            {
              prop: 'returnQty',
              label: '销退数量'
            },
            {
              prop: 'returnPrice',
              label: '销退单价'
            },
            {
              prop: 'returnAmount',
              label: '销退金额'
            },
            {
              prop: 'warehouseName',
              label: '仓库'
            },
            {
              prop: 'placeCode',
              label: '库位'
            }
          ],
      formField: {
        purReturnType: '',
        purReturnTypeName: '',
        purReturnCode: '',
        dlrCode: '',
        dlrShortName: '',
        returnDate: '',
        returnAmount: '',
        returnReason: '',
        purReturnId: ''
      }
    }
  },

  methods: {
    closeEdit() {
      this.$emit('update:popupsVisible', false)
    }
  }
}
</script>
